package top.lingkang.fas.admin.web.impl;

import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.CodeGenerator;
import top.lingkang.fas.admin.utils.IdUtils;

/**
 * @author lingkang
 * created by 2025/7/20 2:35
 */
public class CustomLineCaptcha extends LineCaptcha {
    private String id;
    private int answer;

    public CustomLineCaptcha(int width, int height) {
        super(width, height);
        setGenerator(new CodeGenerator() {
            @Override
            public String generate() {
                Captcha generate = MathCaptchaGenerator.generate();
                answer = generate.getAnswer();
                return generate.getQuestion();
            }

            @Override
            public boolean verify(String s, String s1) {
                return false;
            }
        });
    }

    @Override
    public void createCode() {
        super.createCode();
        id = IdUtils.nextId36();
    }

    public String getId() {
        return id;
    }

    public int getAnswer() {
        return answer;
    }
}
